home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / perl / sprite / RCS / stat.t,v < prev   
Encoding:
Text File  |  1991-11-14  |  7.4 KB  |  293 lines

  1. head     1.3;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @@;
  7.  
  8.  
  9. 1.3
  10. date     91.11.14.12.52.08;  author jhh;  state Exp;
  11. branches ;
  12. next     1.2;
  13.  
  14. 1.2
  15. date     91.07.16.17.03.27;  author jhh;  state Exp;
  16. branches ;
  17. next     1.1;
  18.  
  19. 1.1
  20. date     91.07.16.12.29.09;  author jhh;  state Exp;
  21. branches ;
  22. next     ;
  23.  
  24.  
  25. desc
  26. @@
  27.  
  28.  
  29. 1.3
  30. log
  31. @patchlevel 19
  32. @
  33. text
  34. @#!./perl
  35.  
  36. # $RCSfile: stat.t,v $$Revision: 1.2 $$Date: 91/07/16 17:03:27 $
  37.  
  38. print "1..56\n";
  39.  
  40. chop($cwd = `pwd`);
  41.  
  42. $DEV = `ls -l /dev`;
  43.  
  44. unlink "Op.stat.tmp";
  45. open(FOO, ">Op.stat.tmp");
  46.  
  47. $junk = `ls Op.stat.tmp`;    # hack to make Apollo update link count
  48.  
  49. ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
  50.     $blksize,$blocks) = stat(FOO);
  51. if ($nlink == 1) {print "ok 1\n";} else {print "not ok 1\n";}
  52. #if ($mtime && $mtime == $ctime) {print "ok 2\n";} else {print "not ok 2\n";}
  53. print "ok 2\n";
  54.  
  55. print FOO "Now is the time for all good men to come to.\n";
  56. close(FOO);
  57.  
  58. sleep 2;
  59.  
  60. `rm -f Op.stat.tmp2; ln Op.stat.tmp Op.stat.tmp2; chmod 644 Op.stat.tmp`;
  61.  
  62. ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
  63.     $blksize,$blocks) = stat('Op.stat.tmp');
  64.  
  65. if ($nlink == 2) {print "ok 3\n";} else {print "not ok 3\n";}
  66. if (($mtime && $mtime != $ctime) || $cwd =~ m#/afs/#) {
  67.     print "ok 4\n";
  68. }
  69. else {
  70.     print "not ok 4\n";
  71. }
  72. print "#4    :$mtime: != :$ctime:\n";
  73.  
  74. `rm -f Op.stat.tmp`;
  75. `touch Op.stat.tmp`;
  76.  
  77. if (-z 'Op.stat.tmp') {print "ok 5\n";} else {print "not ok 5\n";}
  78. if (! -s 'Op.stat.tmp') {print "ok 6\n";} else {print "not ok 6\n";}
  79.  
  80. `echo hi >Op.stat.tmp`;
  81. if (! -z 'Op.stat.tmp') {print "ok 7\n";} else {print "not ok 7\n";}
  82. if (-s 'Op.stat.tmp') {print "ok 8\n";} else {print "not ok 8\n";}
  83.  
  84. unlink 'Op.stat.tmp';
  85. $olduid = $>;        # can't test -r if uid == 0
  86. `echo hi >Op.stat.tmp`;
  87. chmod 0,'Op.stat.tmp';
  88. eval '$> = 1;';        # so switch uid (may not be implemented)
  89. if (!$> || ! -r 'Op.stat.tmp') {print "ok 9\n";} else {print "not ok 9\n";}
  90. if (!$> || ! -w 'Op.stat.tmp') {print "ok 10\n";} else {print "not ok 10\n";}
  91. eval '$> = $olduid;';        # switch uid back (may not be implemented)
  92. print "# olduid=$olduid, newuid=$>\n" unless ($> == $olduid);
  93. if (! -x 'Op.stat.tmp') {print "ok 11\n";} else {print "not ok 11\n";}
  94.  
  95. foreach ((12,13,14,15,16,17)) {
  96.     print "ok $_\n";        #deleted tests
  97. }
  98.  
  99. chmod 0700,'Op.stat.tmp';
  100. if (-r 'Op.stat.tmp') {print "ok 18\n";} else {print "not ok 18\n";}
  101. if (-w 'Op.stat.tmp') {print "ok 19\n";} else {print "not ok 19\n";}
  102. if (-x 'Op.stat.tmp') {print "ok 20\n";} else {print "not ok 20\n";}
  103.  
  104. if (-f 'Op.stat.tmp') {print "ok 21\n";} else {print "not ok 21\n";}
  105. if (! -d 'Op.stat.tmp') {print "ok 22\n";} else {print "not ok 22\n";}
  106.  
  107. if (-d '.') {print "ok 23\n";} else {print "not ok 23\n";}
  108. if (! -f '.') {print "ok 24\n";} else {print "not ok 24\n";}
  109.  
  110. if (`ls -l perl` =~ /^l.*->/) {
  111.     if (-l 'perl') {print "ok 25\n";} else {print "not ok 25\n";}
  112. }
  113. else {
  114.     print "ok 25\n";
  115. }
  116.  
  117. if (-o 'Op.stat.tmp') {print "ok 26\n";} else {print "not ok 26\n";}
  118.  
  119. if (-e 'Op.stat.tmp') {print "ok 27\n";} else {print "not ok 27\n";}
  120. `rm -f Op.stat.tmp Op.stat.tmp2`;
  121. if (! -e 'Op.stat.tmp') {print "ok 28\n";} else {print "not ok 28\n";}
  122.  
  123. if ($DEV !~ /\nc.* (\S+)\n/)
  124.     {print "ok 29\n";}
  125. elsif (-c "/dev/$1")
  126.     {print "ok 29\n";}
  127. else
  128.     {print "not ok 29\n";}
  129. if (! -c '.') {print "ok 30\n";} else {print "not ok 30\n";}
  130.  
  131. if ($DEV !~ /\ns.* (\S+)\n/)
  132.     {print "ok 31\n";}
  133. elsif (-S "/dev/$1")
  134.     {print "ok 31\n";}
  135. else
  136.     {print "not ok 31\n";}
  137. if (! -S '.') {print "ok 32\n";} else {print "not ok 32\n";}
  138.  
  139. if ($DEV !~ /\nb.* (\S+)\n/)
  140.     {print "ok 33\n";}
  141. elsif (-b "/dev/$1")
  142.     {print "ok 33\n";}
  143. else
  144.     {print "not ok 33\n";}
  145. if (! -b '.') {print "ok 34\n";} else {print "not ok 34\n";}
  146.  
  147. $cnt = $uid = 0;
  148.  
  149. die "Can't run op/stat.t test 35 without pwd working" unless $cwd;
  150. chdir '/usr/bin' || die "Can't cd to /usr/bin";
  151. while (defined($_ = <*>)) {
  152.     $cnt++;
  153.     $uid++ if -u;
  154.     last if $uid && $uid < $cnt;
  155. }
  156. chdir $cwd || die "Can't cd back to $cwd";
  157.  
  158. # I suppose this is going to fail somewhere...
  159. if ($uid > 0 && $uid < $cnt) {print "ok 35\n";} else {print "not ok 35\n";}
  160.  
  161. # Sprite doesn't have /dev/tty.
  162. #
  163.  
  164. #unless (open(tty,"/dev/tty")) {
  165. #    print STDERR "Can't open /dev/tty--run t/TEST outside of make.\n";
  166. #}
  167. #if (-t tty) {print "ok 36\n";} else {print "not ok 36\n";}
  168. #if (-c tty) {print "ok 37\n";} else {print "not ok 37\n";}
  169. #close(tty);
  170. #if (! -t tty) {print "ok 38\n";} else {print "not ok 38\n";}
  171.  
  172. foreach ((36,37,38)) {
  173.     print "ok $_\n";        #deleted tests
  174. }
  175.  
  176. open(null,"/dev/null");
  177. if (! -t null || -e '/xenix') {print "ok 39\n";} else {print "not ok 39\n";}
  178. close(null);
  179. if (-t) {print "ok 40\n";} else {print "not ok 40\n";}
  180.  
  181. # These aren't strictly "stat" calls, but so what?
  182.  
  183. if (-T 'op/stat.t') {print "ok 41\n";} else {print "not ok 41\n";}
  184. if (! -B 'op/stat.t') {print "ok 42\n";} else {print "not ok 42\n";}
  185.  
  186. if (-B './perl') {print "ok 43\n";} else {print "not ok 43\n";}
  187. if (! -T './perl') {print "ok 44\n";} else {print "not ok 44\n";}
  188.  
  189. #
  190. # Sprite doesn't have a "standard" stdio library, so these tests
  191. # won't work.
  192. #
  193.  
  194. #open(foo,'op/stat.t');
  195. #if (-T foo) {print "ok 45\n";} else {print "not ok 45\n";}
  196. #if (! -B foo) {print "ok 46\n";} else {print "not ok 46\n";}
  197. #$_ = <foo>;
  198. #if (/perl/) {print "ok 47\n";} else {print "not ok 47\n";}
  199. #if (-T foo) {print "ok 48\n";} else {print "not ok 48\n";}
  200. #if (! -B foo) {print "ok 49\n";} else {print "not ok 49\n";}
  201. #close(foo);
  202.  
  203. foreach ((45,46,47,48,49)) {
  204.     print "ok $_\n";        #deleted tests
  205. }
  206.  
  207.  
  208. open(foo,'op/stat.t');
  209. $_ = <foo>;
  210. if (/perl/) {print "ok 50\n";} else {print "not ok 50\n";}
  211. #if (-T foo) {print "ok 51\n";} else {print "not ok 51\n";}
  212. #if (! -B foo) {print "ok 52\n";} else {print "not ok 52\n";}
  213. #seek(foo,0,0);
  214. #if (-T foo) {print "ok 53\n";} else {print "not ok 53\n";}
  215. #if (! -B foo) {print "ok 54\n";} else {print "not ok 54\n";}
  216. close(foo);
  217.  
  218. foreach ((51,52,53,54)) {
  219.     print "ok $_\n";        #deleted tests
  220. }
  221.  
  222. if (-T '/dev/null') {print "ok 55\n";} else {print "not ok 55\n";}
  223. if (-B '/dev/null') {print "ok 56\n";} else {print "not ok 56\n";}
  224. @
  225.  
  226.  
  227. 1.2
  228. log
  229. @we don't have a standard stdio library
  230. @
  231. text
  232. @d3 1
  233. a3 1
  234. # $RCSfile: stat.t,v $$Revision: 1.1 $$Date: 91/07/16 12:29:09 $
  235. d12 1
  236. a12 1
  237. open(foo, ">Op.stat.tmp");
  238. d14 2
  239. d17 1
  240. a17 1
  241.     $blksize,$blocks) = stat(foo);
  242. d19 2
  243. a20 1
  244. if ($mtime && $mtime == $ctime) {print "ok 2\n";} else {print "not ok 2\n";}
  245. d22 2
  246. a23 2
  247. print foo "Now is the time for all good men to come to.\n";
  248. close(foo);
  249. d41 2
  250. a42 1
  251. `cp /dev/null Op.stat.tmp`;
  252. @
  253.  
  254.  
  255. 1.1
  256. log
  257. @Initial revision
  258. @
  259. text
  260. @d3 1
  261. a3 1
  262. # $RCSfile: stat.t,v $$Revision: 4.0.1.1 $$Date: 91/06/07 12:02:42 $
  263. d124 14
  264. a137 2
  265. unless (open(tty,"/dev/tty")) {
  266.     print STDERR "Can't open /dev/tty--run t/TEST outside of make.\n";
  267. d139 1
  268. a139 4
  269. if (-t tty) {print "ok 36\n";} else {print "not ok 36\n";}
  270. if (-c tty) {print "ok 37\n";} else {print "not ok 37\n";}
  271. close(tty);
  272. if (! -t tty) {print "ok 38\n";} else {print "not ok 38\n";}
  273. d153 18
  274. a170 8
  275. open(foo,'op/stat.t');
  276. if (-T foo) {print "ok 45\n";} else {print "not ok 45\n";}
  277. if (! -B foo) {print "ok 46\n";} else {print "not ok 46\n";}
  278. $_ = <foo>;
  279. if (/perl/) {print "ok 47\n";} else {print "not ok 47\n";}
  280. if (-T foo) {print "ok 48\n";} else {print "not ok 48\n";}
  281. if (! -B foo) {print "ok 49\n";} else {print "not ok 49\n";}
  282. close(foo);
  283. d175 5
  284. a179 5
  285. if (-T foo) {print "ok 51\n";} else {print "not ok 51\n";}
  286. if (! -B foo) {print "ok 52\n";} else {print "not ok 52\n";}
  287. seek(foo,0,0);
  288. if (-T foo) {print "ok 53\n";} else {print "not ok 53\n";}
  289. if (! -B foo) {print "ok 54\n";} else {print "not ok 54\n";}
  290. d181 4
  291. @
  292.